package com.kbt.adapter;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.TextView;
import com.kbt.model.data.*;
import com.kbt.activity.R;

import java.util.List;

public class GoodRoadInfoAdapter extends BaseExpandableListAdapter {
	private LayoutInflater inflater = null;
	private List<NewKuaiDiBean> groupList;
//	private List<List<ChildStatusEntity>> childList;
	private Activity context;

	/**
	 * 构造方法
	 *
	 * @param context
	 */
	public GoodRoadInfoAdapter(Activity context,
							   List<NewKuaiDiBean> group_list) {
		this.context =context;
		this.groupList = group_list;
		if(context!=null) {
			inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		}
	}
	/**
	 * 再次赋值
	 *
	 * @param mlist
	 */
	public void setList(List<NewKuaiDiBean> mlist) {
		groupList = mlist;
	}

	/**
	 * 返回一级Item总数
	 */
	@Override
	public int getGroupCount() {
		// TODO Auto-generated method stub
		return groupList.size();
	}

	/**
	 * 返回二级Item总数
	 */
	@Override
	public int getChildrenCount(int groupPosition) {
			return 0;
	}

	/**
	 * 获取一级Item内容
	 */
	@Override
	public Object getGroup(int groupPosition) {
		// TODO Auto-generated method stub
		return groupList.get(groupPosition);
	}

	/**
	 * 获取二级Item内容
	 */
	@Override
	public Object getChild(int groupPosition, int childPosition) {
		return 0;
	}

	@Override
	public long getGroupId(int groupPosition) {
		// TODO Auto-generated method stub
		return groupPosition;
	}

	@Override
	public long getChildId(int groupPosition, int childPosition) {
		// TODO Auto-generated method stub
		return childPosition;
	}

	@Override
	public boolean hasStableIds() {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public View getGroupView(int groupPosition, boolean isExpanded,
			View convertView, ViewGroup parent) {

		GroupViewHolder holder = new GroupViewHolder();

		if (convertView == null) {
			convertView = inflater.inflate(R.layout.group_status_item, null);
		}
		holder.time = (TextView) convertView
				.findViewById(R.id.time);
		holder.content = (TextView) convertView
				.findViewById(R.id.content);

		holder.time.setText(groupList.get(groupPosition).getDatetime());
		holder.content.setText(groupList.get(groupPosition).getRemark());

		return convertView;
	}

	@Override
	public View getChildView(int groupPosition, int childPosition,
			boolean isLastChild, View convertView, ViewGroup parent) {
		return convertView;
	}

	@Override
	public boolean isChildSelectable(int groupPosition, int childPosition) {
		// TODO Auto-generated method stub
		return false;
	}

	private class GroupViewHolder {
		TextView time;
		TextView content;
	}


}
